package com.cac.demo.util.adapter;

import com.github.pagehelper.Page;

import java.io.Serializable;
import java.util.Collection;

/**
 * @className: QueryRespBean
 * @description: （描述这个类的作用）
 * @author:
 * @date: 2024/6/22 10:59:59 周六
 * @version: 1.0
 */
public class QueryRespBean<T>implements Serializable {

    private static final long serialVersionUID = 1L;
    private PageParameter pageParameter = null;
    private Page<T> result = null;

    public QueryRespBean() {
    }

    public QueryRespBean(PageParameter pageParameter, Page<T> result) {
        this.pageParameter = pageParameter;
        this.result = result;
    }

    public PageParameter getPageParameter() {
        if (this.pageParameter == null) {
            this.pageParameter = new PageParameter();
        }

        return this.pageParameter;
    }

    public void setPageParameter(PageParameter pageParameter) {
        this.pageParameter = pageParameter;
    }

    public Page<T> getResult() {
        return this.result;
    }

    public void setResult(Page<T> result) {
        if (result != null && this.pageParameter == null) {
            this.pageParameter = new PageParameter();
            this.pageParameter.setPage(result.getPageNum());
            this.pageParameter.setRows(result.getPageSize());
            this.pageParameter.setTotalCount(result.getTotal());
            this.pageParameter.setTotalPage((long)result.getPages());
        }

        this.result = result;
    }

    public void setResult(Collection<T> result) {
        this.result = (Page)result;
    }

    public String toString() {
        return "QueryRespBean{pageParameter=" + this.pageParameter + ", result=" + this.result + '}';
    }
}
